#include <bits/stdc++.h>

using namespace std;

class Solution
{
public:
    int removeElement(vector<int> &nums, int target)
    {
        // for (auto it = nums.begin(); it != nums.end(); it++)
        // {
        //     if (*it == target)
        //     {
        //         it = nums.erase(it);
        //         it--;
        //     }
        // }
        // return nums.size()
        int slow_index = 0;
        int length = nums.size();
        for (int fast_index = 0; fast_index < length; fast_index++)
        {
            if (nums[fast_index] != target)
            {
                nums[slow_index] = nums[fast_index];
                slow_index++;
            }
        }
        return slow_index;
    }
};

Solution sol;

int main()
{
    vector<int> vec = {3, 2, 2, 3};
    int val = 3;
    cout << sol.removeElement(vec, val) << endl;
    return 0;
}